package clickhouse;



import clickhouse.service.IClickHouseOperation;
import clickhouse.service.impl.ClickHouseDataBase;
import clickhouse.service.impl.ClickHouseWrap;

import java.util.List;
import java.util.Map;

/**
 * @author 王龙海
 * @version 1.0.1
 * @Date 2021-01-12
 * @description ClickHouse工具类
 */
public class ClickHouseUtil {
    static IClickHouseOperation clickHouseOperation;
    static {
        clickHouseOperation= ClickHouseDataBase.getInstance();
    }
    public static ClickHouseWrap getClickHouseWrap(){
        return clickHouseOperation.getClickHouseWrap();
    }
    public static void closeDataBase(ClickHouseWrap clickHouseWrap){
        if(clickHouseWrap==null){
            return;
        }
        clickHouseOperation.closeDataBase(clickHouseWrap);
    }
    public static void batchInsert(ClickHouseWrap clickHouseWrap,String tblName,List<Map<String,Object>> data){
        clickHouseOperation.batchInsertData(clickHouseWrap,tblName,data);
    }
    public static void insertData(ClickHouseWrap clickHouseWrap,String tblName,Map<String,Object> data){
        clickHouseOperation.insertData(clickHouseWrap,tblName,data);
    }
    public static List<Map<String, Object>> getListMapFromSql(ClickHouseWrap clickHouseWrap,String sql){
        return clickHouseOperation.getListMapFromSql(clickHouseWrap,sql);
    }
    public static void deleteData(ClickHouseWrap clickHouseWrap,String tableName,String clause){
        clickHouseOperation.deleteData(clickHouseWrap,tableName,clause);
    }
    public static void updateData(ClickHouseWrap clickHouseWrap,String tableName,Map<String,Object> updateValues,String clause){
        clickHouseOperation.updateData(clickHouseWrap,tableName,updateValues,clause);
    }


    public static List<Map<String, Object>> getListMapFromSql(String sql){
        return clickHouseOperation.getListMapFromSql(sql);
    }
    public static void insertData(String tblName,Map<String,Object> data){
        clickHouseOperation.insertData(tblName,data);
    }
    public static void batchInsert(String tblName,List<Map<String,Object>> data){
         clickHouseOperation.batchInsertData(tblName,data);
    }
    public static void deleteData(String tableName,String clause){
        clickHouseOperation.deleteData(tableName,clause);
    }
    public static void updateData(String tableName,Map<String,Object> updateValues,String clause){
        clickHouseOperation.updateData(tableName,updateValues,clause);
    }
}
